<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes"/>
    <script src="jquery/jquery.js"></script>
    <script>
        $(document).ready(function () {
            $.post("diskFilelist",
                    function (data) {
                        if ('' == data) {
                            alert("对不起，请您先登录你的云盘账户！")
                            return;
                        }
                        var json = JSON.parse(data);
                        var str = "";
                        for (var i = 0; i < json.length; i++) {
                            var obj = json[i]
                            str = str + "<label id=" + obj.id + " title=" + obj.fileDownloadUrl + "><input  type='radio' name='movie' value=" + obj.id + " class=" + obj.openId + " />" + obj.name + "</label><br>";
                        }
                        document.getElementById("movies").innerHTML = str;
                        document.getElementById("movies").style.display = "block";
                        document.getElementById("bottom").style.display = "block";
                    });
        });
        function play() {
            var fileId = $("input[name='movie']:checked").val();
            if (null == fileId) {
                alert("请先勾选一项！")
                return;
            }
            var fileName = $("label#" + fileId).text();
            var fileDownloadUrl = document.getElementById(fileId).title;
            var playUrl = "play?loginStatus=1&fileName=" + fileName + "&fileDownloadUrl=" + encodeURIComponent(fileDownloadUrl);
            $.get(playUrl,
                    function (data) {
                        if ("success" == data) {
                            alert("即将播放！")
                        } else {
                            alert(data)
                        }
                    });
        }
        function doit() {
            var fileId = $("input[name='movie']:checked").val();
            if (null == fileId) {
                alert("请先勾选一项！")
                return;
            }
            var openId = $("input[name='movie']:checked").attr("class");
            $.post("deleteFile?fileId=" + fileId + "&producerOpenId=" + openId,
                    function (data) {
                        if ("success" == data) {
                            alert("删除成功！")
                            document.location.reload();
                        } else {
                            alert("删除失败！")
                        }
                    });
        }
    </script>
</head>
<body style="background:url(img/welcome.jpg); text-align: center;height:665px; width:375px;">
<div style=" display: none;line-height:42px;font-size: 20px" id="movies">
</div>
<div id="bottom" style="display: none;margin-top:120px">

    <button type="button" onclick="play()">投屏</button>

    <button type="button" onclick="doit()">删除</button>

    <button type="button"><a href="index.html">首页</a></button>


</div>
</body>
</html>